package lwf.web.struts.action.math.algebra;


import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lwf.handler.math.algebra.AlgebraProcessHandler;
import lwf.web.struts.action.form.math.ArithmaticsActionForm;
import lwf.web.struts.action.math.ArithmaticsAction;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;




public class AlgebraAction extends ArithmaticsAction {
	
	public ActionForward selectoperation(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		ArithmaticsActionForm soform = (ArithmaticsActionForm) form;
		String datastring = request.getParameter("datastring");
		AlgebraProcessHandler sumdetails = new AlgebraProcessHandler(datastring);
		setSumData(request, sumdetails);
		//set to session
		soform.setSumdetail(sumdetails); //May not be required
		// Write the HTML to response
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out.println(sumdetails.getDisplayFormatter().getFormattedQuestion());
		//the html string value will be retrieved as 'req.responseText'
		// and will be displayed using the element id = questionblock
		out.flush();

		return null; // Not forwarding to anywhere, response is fully-cooked
	}	

} //AlgebraAction
